package com.fantsey.pattern.observer;

public class ObserverPatternDemo {
    public static void main(String[] args) {
        //创建主类（被观察者）
        Subject subject = new Subject();
        //新建3个观察者，观察对象都为Subject对象
        new HexaObserver(subject);
        new OctalObserver(subject);
        new BinaryObserver(subject);
        System.out.println("First state change: 15");
        // 改变被观察者的状态
        subject.setState(15);
        System.out.println("Second state change: 10");
        // 改变被观察者的状态
        subject.setState(10);
    }
}
